feature: add copy-as-code-snippet for requests on the Send page#243
feature: add copy-as-code-snippet for requests on the Send page#243komen205 wants to merge 1 commit into
Conversation
Adds a copy button to the Send request line that opens a menu of code snippet formats, mirroring the View page's export context menu. The snippet is generated directly from the in-progress request input, so requests can be exported as code while editing, before they're sent. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
|
| : undefined; | ||
|
|
||
| const menuItems: Array<ContextMenuItem<void>> = [ | ||
| ...(!isPaidUser ? [ |
There was a problem hiding this comment.
Not sure if this is worth to keep, the whole feature is already gated anyway.
|
@pimterry wyt about this? Is this something you'd like to add? I'd love to have this feature. Lmk your thoughts and I will resolve the conflicts. |
|
Hi @komen205 sorry for the delay! I have seen this, I'm totally on board with the goal, I've just been quite busy elsewhere for a week, and still trying think through the UI design for this. It depends how we want to expose this, and what other similar features we might want in future... There's other options to consider like a menu bar or similar, or footer, or dropdown button attached to the Send button, etc. I'll find time for a proper review and confirm a plan early this week. Out of interest, what are the other features you're interested in? Anything else on the Send page that might be related to this? |

What
Adds the ability to copy a request as a code snippet directly from the Send page, while editing it — without having to send it first and export from the View page.
A new copy button sits in the Send request line (between the URL input and the Send button). Clicking it opens a menu mirroring the View page's export context menu:
Picking a format from the submenu copies the snippet and updates the persisted preferred format (
uiStore.exportSnippetFormat), same as the View page behaviour.How
generateHarRequestFromRequestData()inhar.tsbuilds anExtendedHarRequestfrom not-yet-sent request data (decoded body, raw headers, HTTP/1.1), reusing the existing cookie parsing, postData generation, and non-UTF8 body fallback.generateCodeSnippetFromRequestInput()inexport.tsfeeds that through the same HAR-simplification + httpsnippet conversion as the existing View-page path, which was refactored into a shared helper so both stay in sync (content-length/content-encoding/H2 pseudo-header dropping etc).Tests
Added
test/unit/model/ui/export.spec.tscovering snippet generation from request inputs: simple GET, POST with body (content-length dropped), content-encoding dropped with decoded body used, and a clear failure for invalid URLs. Full unit suite passes (894 tests).🤖 Generated with Claude Code